[Fix #1372] conversion to no collection type forWorkflowModelCollection#1373
[Fix #1372] conversion to no collection type forWorkflowModelCollection#1373fjtirado merged 1 commit intoserverlessworkflow:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses #1372 by improving event payload conversion so workflows listening to a single event no longer need an explicit outputAs(Collection -> firstElement) step to access the first item.
Changes:
- Updated
CollectionConversionUtils.as(...)to acceptIterable<?>and added a fallback conversion path that converts the first element to the requested non-collection type. - Simplified
JacksonModelCollection.as(...)to pass theArrayNodedirectly into the conversion utility. - Updated the fluent DSL test to remove the now-unnecessary
outputAs(...iterator().next())workaround.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| impl/model/src/main/java/io/serverlessworkflow/impl/model/jackson/JacksonModelCollection.java | Routes ArrayNode directly into shared conversion utility to enable single-item conversion. |
| impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java | Broadens input to Iterable and adds “convert first element” behavior for non-collection targets. |
| experimental/test/src/test/java/io/serverlessworkflow/fluent/test/FuncEventFilterTest.java | Removes manual “first element” extraction to validate the improved conversion behavior. |
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:81
- The
@see #as(Collection, Class, BiFunction)reference no longer matches an existing overload after the signature change (the 3-arg method now takesIterable). Update the@seetarget so Javadoc resolves correctly.
/**
* @see #as(Collection, Class, BiFunction)
*/
public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
return as(elements, clazz, (item, type) -> item);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:90
- The
@seetag references#as(Collection, Class, BiFunction), but that overload no longer exists (it is nowas(Iterable, Class, BiFunction)). Update the@seeto point to the correct method signature to avoid broken Javadoc links/doclint failures.
/**
* @see #as(Collection, Class, BiFunction)
*/
public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
return as(elements, clazz, (item, type) -> item);
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:104
- The
@seetag references#as(Collection, Class, BiFunction), but that overload no longer exists after changing the primary API toas(Iterable, ...). Update the Javadoc reference to the correct method signature to avoid broken documentation links.
/**
* @see #as(Collection, Class, BiFunction)
*/
public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
return as(elements, clazz, (item, type) -> item);
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:104
- The Javadoc
@seetag references#as(Collection, Class, BiFunction), but that overload no longer exists (the 3-arg overload is nowas(Iterable, Class, BiFunction)). Update the reference to avoid broken Javadoc links (and potential Javadoc build warnings/failures if doclint is enabled).
…kflowModelCollection Signed-off-by: fjtirado <ftirados@redhat.com>
Fix #1372